home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / C / Mesa / mklib.aix < prev    next >
Encoding:
Text File  |  1997-01-07  |  3.2 KB  |  135 lines

  1. #!/bin/ksh
  2.  
  3. # Make an AIX shared library (tricky!!!)
  4. # Based on a script from Athanasios G. Gaitatzes (gaitat@vnet.ibm.com)
  5. # Improved by Greg Thompson <gregt@visix.com> -gt
  6.  
  7. # First argument is name of output library
  8. # Rest of arguments are object files
  9.  
  10.  
  11. # Name of the library which clients will link with (ex: libMesaGL.a)
  12. LIBRARY=$1
  13.  
  14. # BASENAME = LIBRARY without .a suffix
  15. BASENAME=`echo ${LIBRARY} | sed "s/\.a//g"`
  16.  
  17. # Name of exports file
  18. EXPFILE=${BASENAME}.exp
  19.  
  20. # Name of temporary shared lib file
  21. OFILE=shr.o
  22. ####OFILE=${BASENAME}.o
  23.  
  24. # List of object files to put into library
  25. shift 1
  26. OBJECTS=$*
  27.  
  28.  
  29. # Remove any old files from previous make
  30. rm -f ${LIBRARY} ${EXPFILE} ${OFILE}
  31.  
  32. # Pick a way to use nm -gt
  33. NM=${NM-/bin/nm -eC}
  34.  
  35. # Determine which version of AIX this is
  36. AIXVERSION=`uname -v`
  37.  
  38. # Pick a way to tell the linker there's no entrypoint -gt
  39. case ${AIXVERSION}
  40. {
  41.     3*)
  42.         ENTRY='-e _nostart'
  43.         ;;
  44.     4*)
  45.         ENTRY=-bnoentry
  46.         ;;
  47.     *)
  48.         echo "Error in mklib.aix!"
  49.         exit 1
  50.         ;;
  51. }
  52.  
  53.  
  54. # Other libraries which we may be dependent on.  Since we make the libraries
  55. # in the order libMesaGL.a, libMesaGLU.a, libMesatk.a, libMesaaux.a each
  56. # just depends on its predecessor.
  57. # modified to make otherlibs in the form of -lfoo -gt
  58. OTHERLIBS=`ls ../lib/*.a | sed "s/..\/lib\/lib/-l/g" | sed "s/\.a//g"`
  59.  
  60. ##echo OTHERLIBS are ${OTHERLIBS}
  61.  
  62.  
  63. # Make exports (.exp) file header
  64. echo "#! ${LIBRARY}" > ${EXPFILE}
  65.  
  66. # Append list of exported symbols to exports file -gt
  67. case ${AIXVERSION}
  68. {
  69.     3*)
  70.     ${NM} ${OBJECTS} | awk -F'|' '{
  71.         if ($3 != "extern" || substr($7,1,1) == " ") continue
  72.         sub ("  *", "", $1); sub ("  *", "", $7)
  73.         if ( (($7 == ".text") || ($7 == ".data") || ($7 == ".bss"))  \
  74.             && ( substr($1,1,1) != ".")) {
  75.         if (substr ($1, 1, 7) != "__sinit" &&
  76.             substr ($1, 1, 7) != "__sterm") {
  77.             if (substr ($1, 1, 5) == "__tf1")
  78.             print (substr ($1, 7))
  79.             else if (substr ($1, 1, 5) == "__tf9")
  80.             print (substr ($1, 15))
  81.             else
  82.             print $1
  83.         }
  84.         }
  85.     }' | sort -u >> ${EXPFILE}
  86.     ;;
  87.  
  88.     4*)
  89.     ${NM} ${OBJECTS} | awk '{
  90.         if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
  91.             && ( substr($1,1,1) != ".")) {
  92.         if (substr ($1, 1, 7) != "__sinit" &&
  93.             substr ($1, 1, 7) != "__sterm") {
  94.             if (substr ($1, 1, 5) == "__tf1")
  95.             print (substr ($1, 7))
  96.             else if (substr ($1, 1, 5) == "__tf9")
  97.             print (substr ($1, 15))
  98.             else
  99.             print $1
  100.         }
  101.         }
  102.     }' | sort -u >> ${EXPFILE}
  103.     ;;
  104. }
  105.  
  106.  
  107. # This next line is a hack to allow full compatibility with IBM's OpenGL
  108. # libraries.  IBM mistakenly exports glLoadIdentity from the libGLU.a
  109. # library.  We have to do the same thing.  Problem reported by Yemi Adesanya
  110. # (adesanya@afsmail.cern.ch) and Patrick Brown (pbrown@austin.ibm.com)
  111. if [ "${BASENAME}" = libMesaGLU ] ; then
  112.     echo "glLoadIdentity" >> ${EXPFILE}
  113. fi
  114.  
  115.  
  116. # Make the shared lib file
  117. cc -o ${OFILE} ${OBJECTS} -L../lib ${OTHERLIBS} -lX11 -lm -lc -bE:${EXPFILE} -bM:SRE ${ENTRY}
  118.  
  119.  
  120. # Make the .a file
  121. ar ruv ${LIBRARY} ${OFILE}
  122.  
  123. # Put exports file in Mesa lib directory
  124. mv ${EXPFILE} ../lib
  125.  
  126. # Remove OFILE
  127. rm -f ${OFILE}
  128.  
  129.  
  130. #NOTES
  131. # AIX 4.x /usr/bin/nm -B patch from ssclift@mach.me.queensu.ca (Simon Clift)
  132. # Robustified symbol extraction for AIX 3 and 4
  133. #   Greg Thompson <gregt@visix.com>
  134.  
  135.